from accounts import *
from opertion import *
import random
init_account()
while True:
    print("**************************************")
    print("***** 1.登录           2.注册***********")
    print("*****          3.退出         *********")
    print("**************************************")
    lis = read_account()
    u = int(input("登录 or 注册："))
    if u == 1:
        user = input("请输入卡号：")
        if user in lis:
            pwd = input("请输入密码:")
            if pwd == lis[user]['pwd']:
                print("登陆成功")
                while True:
                    print("**************************************")
                    print("***** 1.取款           2.存款***********")
                    print("***** 3.查询           4.退出***********")
                    print("**************************************")
                    m = int(input("请输入您的操作："))
                    account = read_account()
                    if m == 1:
                        withdrowal(account, user)
                    elif m == 2:
                        deposit(account, user)
                    elif m == 3:
                        find_cash(account, user)
                    elif m == 4:
                        print("欢迎使用，再见！")
                        break
                    else:
                        print("无效输入，请重新输入")
        else:
            print("卡号不存在！")
            continue
    elif u==2:
        pasd = input("请您输入密码：")
        users = random.randint(100000,999999)
        print(f"您的卡号是：{users}")
        add_acc(users,pasd)
        print("注册成功!")
        continue
    elif u==3:
        print("退出成功！")
        break
    else :
        print("输入失败请重新输入！")
        break





